import { PoemType } from 'src/modules/poem-type/entities/poem-type.entity';
import { Poem } from 'src/modules/poem/entities/poem.entity';
import {
  Column,
  CreateDateColumn,
  Entity,
  ManyToMany,
  ManyToOne,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

@Entity()
export class PoemTag {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column({ nullable: true })
  description: string;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

  @ManyToOne(() => PoemType, (poemType) => poemType.poemTags)
  poemType: PoemType;

  @ManyToMany(() => Poem, (poem) => poem.poemTags)
  poems: Poem[];
}
